Skip to content

Refactor: marker question and --config ask through one Terminal seam - #21

Merged
Skeyelab merged 1 commit into
mainfrom
refactor/terminal-seam
Nov 13, 2026
Merged

Skeyelab merged 1 commit into
mainfrom
refactor/terminal-seam

Conversation

@Skeyelab

Copy link
Copy Markdown
Member

Summary

-_resolve_marker_choice: sys.stdin.isatty() / input()
-_run_config:            sys.stdin.isatty() / input()
+class Terminal: interactive, ask(prompt) -> str | None   # None = no one there / EOF
+main(argv, terminal=None)
+  _run_send(args, terminal) -> _resolve_marker_choice(robot, configured, terminal)
+  _run_config(args, terminal)

Marker order is unchanged: flag → contacts.toml setting → ask the person → refuse.

Evidence

  • Tests hand main() a FakeTerminal(["n"]), or FakeTerminal(None) for an agent. They no longer monkeypatch isatty/input. An autouse fixture makes every test agent-like by default, so nothing reads the real stdin.
  • New: test_a_person_at_the_terminal_can_decline_the_marker (red → green).
  • New: test_a_person_who_ends_input_at_the_marker_question_sends_nothing. Mutation-checked: making no-answer count as yes fails it.
  • 128 passed.

Merge Danger

Door: two-way

Blast Radius: none

🤖 Generated with Claude Code

https://claude.ai/code/session_01VCgWWsJbTMzsnA2WJkmsjC

main(argv, terminal=...) takes the person running the command. Tests hand it
a FakeTerminal with scripted replies (or none, the way an agent runs) instead
of monkeypatching sys.stdin.isatty and builtins.input. EOF at the marker
question is now a clean refusal rather than a traceback; nothing is sent
either way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCgWWsJbTMzsnA2WJkmsjC
@claude

claude Bot commented Nov 13, 2026

Copy link
Copy Markdown

Review of the Terminal seam refactor. No blocking issues found.

  • Marker refusal is preserved. --robot/--no-robot still wins, then the contact's configured marker, then terminal.ask(). ask() returns None when stdin is not a tty, so a non-interactive caller with no stated choice is still refused with exit 1. test_non_interactive_send_must_state_the_marker_choice still covers this, now through the autouse FakeTerminal(None).
  • EOF and Ctrl-C at the marker prompt now return None and refuse. They used to raise. This is the safe direction, and the new test covers it.
  • --config is still gated on terminal.interactive, so an agent cannot reach it.
  • Test isolation works. main() reads TERMINAL at call time, so the autouse monkeypatch takes effect. No test can touch the real stdin.
  • Scoping, chat.db read-only mode, the typedstream decoder, the contacts.toml lookup and the README are not touched by this diff. I did not review them here.
  • Privacy: the diff adds only +1555…/+15555550123 placeholders. No real identifiers.

Nits, non-blocking:

  1. After an interactive EOF at the marker question, the error says "pass --robot or --no-robot when not running interactively". That is misleading when a human was present. Consider a separate message.
  2. Some tests now have a stray blank line after the def line and an unused monkeypatch parameter, for example test_non_interactive_send_proceeds_when_told.
  3. main(..., terminal=...) is a public injection point. It is harmless today because no CLI path sets it. Keep it that way.

🤖 Generated with Claude Code

@Skeyelab
Skeyelab added this pull request to stack #25 November 13, 2026 17:08
@Skeyelab
Skeyelab merged commit a14f2c8 into main Nov 13, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant